def caesar_encrypt(plaintext, shift):
    """凯撒加密函数"""
    encrypted_text = []
    for char in plaintext:
        if char.isalpha():
            # 判断字符是大写还是小写
            offset = 65 if char.isupper() else 97
            # 计算加密后的字符
            encrypted_char = chr((ord(char) - offset + shift) % 26 + offset)
            encrypted_text.append(encrypted_char)
        else:
            # 非字母字符直接添加
            encrypted_text.append(char)
    return ''.join(encrypted_text)

def main():
    plaintext = input("请输入明文: ")
    shift = int(input("请输入偏移量 (1-25): "))

    # 加密
    ciphertext = caesar_encrypt(plaintext, shift)
    print(f"加密后的密文: {ciphertext}")

if __name__ == "__main__":
    main()
